package wangjg.xuexiban.util;

import android.os.Environment;

public class Constant {

	public static final String SHARED_PREFERENCES_NAME = "setting";
	
	public static final String KEY_DATA_DIR = "data.dir";
	
	// /sdcard
	public static final String SDCARD_PATH = Environment.getExternalStorageDirectory().getPath();
	
	public static final String DEFAULT_DATA_ROOT = SDCARD_PATH + "/xuexiban/category/";
	
	public static final String CUSTOM_CATEGORY = "custom-";
	
	public static final String DATA_LIST_FILENAME = "list.txt";
	
//	public static final String DEFAULT_DOWN_URL = "http://192.168.0.102/cardlist.html";
	public static final String DEFAULT_DOWN_URL = "http://192.168.8.66/springmvc/card/1.xhtml";
	
	/* 网络版 */
	public static final String WEB_CACHE_DIR = SDCARD_PATH + "/xuexiban/cache";
	public static final String URL_IMG_PREFIX = getHostUrl()+"/file/image/orig";
	public static final String URL_FILE_PREFIX = getHostUrl()+"/file/download";
	public static final String URL_CATEGORY_DOWN = getHostUrl()+"/mobile/category/list.json";
	public static final String URL_CARD_DOWN = getHostUrl()+"/mobile/card/list.json?categoryId=";
	
	private static final String getHostUrl(){
		final String URL_HOST_DEBUG = "http://192.168.8.66/springmvc";
		final String URL_HOST_RELEASE = "https://hm1801.duckdns.org:60080/springmvc";
		if(Env.isEmulator()){
			return URL_HOST_DEBUG;
		}else{
			return URL_HOST_RELEASE;
		}
	}
	
	public static final String picUrl(String path){
		return URL_IMG_PREFIX+path;
	}
	
	public static final String fileUrl(String path){
		return URL_FILE_PREFIX+path;
	}
	
}
